var app = getApp();
Page({
  data: {},
  onLoad: function() {},
  getuserinfo: function(e) {
    wx.getLocation({
      success(res) {
        wx.request({
          url: 'https://www.mamingwang.cn/api/dizhi/jingwei',
          data: {
            jingwei: res.latitude + "," + res.longitude
          },
          method: "post",
          success(res) {
            wx.setStorage({
              key: 'city',
              data: res.data.result.addressComponent.province + res.data.result.addressComponent.city,
            })
          }
        })
      }
    })
    var openid = wx.getStorageSync("openid");
    wx.getUserInfo({
      lang: "zh_CN",
      success(res) {
        wx.setStorage({
          key: 'nickname',
          data: res.userInfo.nickName,
        })
        wx.setStorage({
          key: 'touxiang',
          data: res.userInfo.avatarUrl,
        })
        wx.request({
          url: 'https://www.mamingwang.cn/api/openid/userinfo',
          data: {
            openid: openid,
            sex: res.userInfo.gender,
            diqu: res.userInfo.country + "-" + res.userInfo.province + "-" + res.userInfo.city,
            nickname: res.userInfo.nickName,
            touxiang: res.userInfo.avatarUrl
          },
          success(res) {
            console.log(res)
            wx.reLaunch({
              url: '../../shangquan/shangquan',
            })
          }
        })
      }
    })
  }
})